package com.xiaoxi.checkpasswordserver.domain;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

/**
 * @ClassName ContainUserNameCheck
 * @Description
 * @Author xiaoxi
 * @Date 2022/7/11 21:49
 * @Version 1.0
 */
@Component
@Data
public class ContainUserNameCheck implements IPasswordCheck {

    private String userName;

    public CheckResult check(String password, CheckResult checkResult) {
        if(StringUtils.isNotBlank(userName)) {
            if (password.toLowerCase().contains(this.userName.toLowerCase())) {
                checkResult.getErrorReason().add("密码不应包含用户名信息");
            }
        }
        return checkResult;
    }
}
